package com.SouthernWall_404.age_tool.common.world.block.RedStoneComponent;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.DiodeBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;

public abstract class AbstractRedStoneOutputBlock extends DiodeBlock {
    public static final DirectionProperty FACING = DiodeBlock.FACING;
    public static final BooleanProperty POWERED = DiodeBlock.POWERED;

    public AbstractRedStoneOutputBlock(Properties properties) {
        super(properties);
        this.registerDefaultState(this.stateDefinition.any()
                .setValue(FACING, Direction.NORTH)
                .setValue(POWERED, Boolean.FALSE));
    }


    
    @Override
    protected int getDelay(BlockState blockState) {
        return 0;
    }

    @Override
    protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
        builder.add(FACING, POWERED);
//        super.createBlockStateDefinition(builder);
    }

    protected abstract int getOutput(Level level, BlockPos blockPos, BlockState blockState);

    @Override
    protected int getOutputSignal(BlockGetter blockGetter, BlockPos blockPos, BlockState blockState) {
        if (blockGetter instanceof Level level) {
            return getOutput(level, blockPos, blockState);
        }
        return super.getOutputSignal(blockGetter, blockPos, blockState);
    }
}